package blah;

import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import javax.swing.JButton;
import javax.swing.JFrame;

public class ButtonBean extends JFrame {

  GridLayout gridLayout1 = new GridLayout();
  JButton incrementButton = new JButton();
  JButton resetButton = new JButton();
  JButton decrementButton = new JButton();

  private PropertyChangeSupport listeners = new PropertyChangeSupport(this);

  public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
    listeners.addPropertyChangeListener(l);
  }

  public synchronized void removePropertyChangeListener(PropertyChangeListener l) {
    listeners.removePropertyChangeListener(l);
  }

  protected void fireMessage(String message) {
    listeners.firePropertyChange(new PropertyChangeEvent(this, "Message", null, message));
  }
  
  public ButtonBean() {
  	Container jPanel1 = this.getContentPane();
    incrementButton.setBackground(Color.green);
    incrementButton.setActionCommand("increment");
    incrementButton.setText("+");
    incrementButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        fireMessage("increment");
      }
    });
    jPanel1.setLayout(gridLayout1);
    resetButton.setBackground(Color.green);
    resetButton.setForeground(Color.red);
    resetButton.setActionCommand("reset");
    resetButton.setText("0");
    resetButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        fireMessage("reset");
      }
    });
    decrementButton.setBackground(Color.green);
    decrementButton.setActionCommand("decrement");
    decrementButton.setText("-");
    decrementButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        fireMessage("decrement");
      }
    });
    this.setBackground(Color.orange);
    jPanel1.setBackground(Color.red);
    jPanel1.add(incrementButton, null);
    jPanel1.add(resetButton, null);
    jPanel1.add(decrementButton, null);
  }
}